# mainUI.py
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QHBoxLayout, QWidget, QListWidget, QTextEdit, QSplitter, QSizePolicy
from PyQt5.QtCore import Qt

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("软件2246班课设一组———算法可视化系统AVS 1.0")
        self.setGeometry(100, 100, 900, 600)  # 设置窗口的大小和位置

        # 创建一个中央Widget
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # 创建一个水平布局
        main_layout = QHBoxLayout(central_widget)

        # 创建一个QSplitter，用于控制各部分的大小
        splitter = QSplitter(Qt.Horizontal)

        # 左侧菜单选项
        self.menu_list = QListWidget()
        self.menu_list.addItems(["冒泡排序", "TSP旅行商问题", "图着色问题"])
        self.menu_list.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        splitter.addWidget(self.menu_list)

        # 中间绘图区域
        self.drawing_area = QLabel("绘图区域")
        self.drawing_area.setAlignment(Qt.AlignCenter)
        self.drawing_area.setStyleSheet("background-color: lightgray; font-size: 20px;")
        self.drawing_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        splitter.addWidget(self.drawing_area)

        # 右侧代码展示区域
        self.code_display = QTextEdit()
        self.code_display.setPlainText("# 在此处显示代码")
        self.code_display.setStyleSheet("font-family: Courier; font-size: 14px;")
        self.code_display.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        splitter.addWidget(self.code_display)

        # 设置各部分的比例
        splitter.setSizes([180, 450, 270])  # 根据比例进行调整

        # 将QSplitter添加到布局中
        main_layout.addWidget(splitter)

def main():
    app = QApplication(sys.argv)

    window = MainWindow()
    window.show()

    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
